package com.elder.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.elder.business.domain.HealthCheckRecords;
import com.elder.business.domain.HealthCheckRecordsDTO;
import com.elder.business.service.IHealthCheckRecordsService;
import com.elder.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.elder.common.annotation.Log;
import com.elder.common.core.controller.BaseController;
import com.elder.common.core.domain.AjaxResult;
import com.elder.common.enums.BusinessType;
import com.elder.common.utils.poi.ExcelUtil;
import com.elder.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author elder
 * @date 2024-04-11
 */
@RestController
public class HealthCheckRecordsController extends BaseController
{
    @Autowired
    private IHealthCheckRecordsService healthCheckRecordsService;

    /**
     * 查询【请填写功能名称】列表
     */
    @Anonymous
    @GetMapping("business/healthCheck/list")
    public TableDataInfo list(String elderName, String checkupName ,String checkupType,String startTime,String endTime,Integer pageNum,Integer pageSize)
    {
        return healthCheckRecordsService.getHealthCheckRecordsList(elderName, checkupName,checkupType,startTime, endTime, pageNum, pageSize);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @Anonymous
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("business/healthCheck/export")
    public void export(HttpServletResponse response, HealthCheckRecords healthCheckRecords)
    {
        List<HealthCheckRecords> list = healthCheckRecordsService.selectHealthCheckRecordsList(healthCheckRecords);
        ExcelUtil<HealthCheckRecords> util = new ExcelUtil<HealthCheckRecords>(HealthCheckRecords.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @Anonymous
    @GetMapping(value = "business/healthCheck/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(healthCheckRecordsService.selectHealthCheckRecordsById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @Anonymous
    @Log(title = "新增体检", businessType = BusinessType.INSERT)
    @PostMapping("business/healthCheck")
    public AjaxResult add(@RequestBody HealthCheckRecordsDTO healthCheckRecords)
    {
        return toAjax(healthCheckRecordsService.insertHealthCheckRecords(healthCheckRecords));
    }

    /**
     * 修改【请填写功能名称】
     */
    @Anonymous
    @Log(title = "修改体检信息", businessType = BusinessType.UPDATE)
    @PutMapping("business/healthCheck")
    public AjaxResult edit(@RequestBody HealthCheckRecordsDTO healthCheckRecords)
    {
        return toAjax(healthCheckRecordsService.updateHealthCheckRecords(healthCheckRecords));
    }

    /**
     * 删除【请填写功能名称】
     */
    @Anonymous
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("business/healthCheck/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(healthCheckRecordsService.deleteHealthCheckRecordsByIds(ids));
    }
}
